package main

import (
	"fmt"
	"github.com/vmihailenco/msgpack"
	"reflect"
)

type Test struct {
	Name string
	Data []byte
}

func main() {
	var countryCapitalMap map[string]string /*创建集合 */
	countryCapitalMap = make(map[string]string)

	/* map插入key - value对,各个国家对应的首都 */
	countryCapitalMap["France"] = "巴黎"
	countryCapitalMap["Italy"] = "罗马"
	countryCapitalMap["Japan"] = "东京"
	countryCapitalMap["India "] = "新德里"
	fmt.Println("原数据-", countryCapitalMap)

	test := Test{Name: "测试", Data: []byte("了")}
	//in := map[string]interface{}{"foo": uint32(123456789), "hello": "world"}
	//in := countryCapitalMap
	//res, err := msgpack.Marshal(in)
	res, err := msgpack.Marshal(test)
	if err != nil {
		fmt.Printf("序列化失败")
	}
	//fmt.Sprintf("数据类型%T", b)
	fmt.Println(reflect.TypeOf(res))
	fmt.Println("序列化数据--", res)

}
